<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="评论管理">
<form id="searchForm" class="form-panel">
    <ul class="panel-content">
        <li>
            <div class="control-group span8">
                <label class="control-label">商品编号：</label>
                <div class="controls">
                  <input type="text" name="productID"  value="${e.productID!""}">
                </div>
            </div>
            <div class="control-group span8">
                <label class="control-label">会员账号：</label>
                <div class="controls">
                    <input type="text" name="account"  value="${e.account!""}">
                </div>
            </div> 
            <div class="control-group span8">
                <label class="control-label">订单编号</label>
                <div class="controls">
                    <input type="text" name="orderID"  value="${e.orderID!""}">
                </div>
            </div>          
        </li>
        <li>
            <div class="form-actions span8">
                <button   type="submit" class="button  button-primary"  >
                    查询
                </button>
                <a  class="button button-danger"  onclick="return updateFunction('updateStatusY')">
                    显示
                </a>
                <a  class="button button-danger"  onclick="return updateFunction('updateStatusN')">
                    不显示
                </a>
            </div>
        </li>

    </ul>
</form>
<div id="grid"></div>

<script>
    var Grid = BUI.Grid,
            Store = BUI.Data.Store,
            columns = [
                {title : '商品编号',dataIndex :'productID', width:100},
                {title : '会员账号',dataIndex :'account', width:100},
                {title : '订单编号',dataIndex : 'orderID',width:100},
                {title : '评论内容',dataIndex : 'content',width:100},
                {title : '评论日期',dataIndex : 'createdate',width:100},
                {title : '评论星级',dataIndex : 'star',width:100},
                {title : '是否显示',dataIndex : 'status',width:100, renderer:function(data){
                    if(data == "y"){
                        return '<img src="${basepath}/resource/images/action_check.gif">';
                    } else {
                        return '<img src="${basepath}/resource/images/action_delete.gif">';
                    }
                }},
                {title : '操作',dataIndex : 'id',width:200,renderer : function (value,obj) {
                    if(obj.reply) {
                        return '<a href="${basepath}/manage/comment/toEdit?id=' + value + '&update=y">修改回复</a>';
                    }else{
                        return '<a href="${basepath}/manage/comment/toEdit?id=' + value + '">回复</a>';
                    }
                }}
            ];
    var form = new BUI.Form.HForm({
        srcNode : '#searchForm'
    }).render();
    var params=form.serializeToObject();
    params.length='10';
    form.on('beforesubmit',function(ev) {
        var obj = form.serializeToObject();
        obj.start = 0; //返回第一页
        store.load(obj);
        return false;
    });
    var store = new Store({
                url : 'loadData',
                autoLoad:true, //自动加载数据
                params : { //配置初始请求的参数
                    length : '10',
                    status:$("#status").val()
                },
                pageSize:10,	// 配置分页数目
                root : 'list',
                totalProperty : 'total'
            }),
            grid = new Grid.Grid({
                render:'#grid',
                columns : columns,
                loadMask: true, //加载数据时显示屏蔽层
                store: store,
                plugins : [Grid.Plugins.CheckSelection], // 插件形式引入多选表格

                // 底部工具栏
                bbar:{
                    pagingBar:true
                }
            });
    grid.render();

    //删除选中的记录
    function updateFunction(action){
        var selections = grid.getSelection();
        var ids=new Array();
        for(var i=0;i<selections.length;i++){
            ids[i]=selections[i].id.toString()
        }
        $.ajax({
            type: "POST",
            url: "${basepath}/manage/comment/"+action,
            dataType: "json",
            data: {
                ids:ids
            },
            success: function (data) {
                console.log(111);
                var obj = form.serializeToObject();
                obj.start = 0; //返回第一页
                store.load(obj);
            }
        });

    }

</script>
</@page.pageBase>